package com.cqie.rbac.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.cqie.rbac.bo.ClassBo;
import com.cqie.rbac.entity.UserClassView;
import com.cqie.rbac.mapper.UserClassViewMapper;
import com.cqie.rbac.service.IUserClassViewService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cqie.rbac.util.MyPageHelper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * VIEW 服务实现类
 * </p>
 *
 * @author 单机吧
 * @since 2021-10-12
 */
@Service
public class UserClassViewServiceImpl extends ServiceImpl<UserClassViewMapper, UserClassView> implements IUserClassViewService {

    @Override
    public List<UserClassView> getClassList(ClassBo bo) {
        if (bo.getPageNum() == null || bo.getPageSize() == null){
            bo.setPageNum(1);
            bo.setPageSize(10);
        }
        MyPageHelper.startPage(bo);
        LambdaQueryWrapper<UserClassView> lqw = Wrappers.lambdaQuery();
        lqw.likeRight(bo.getClass_name() != null,UserClassView::getClassName,bo.getClass_name());
        lqw.eq(bo.getClass_no() != null,UserClassView::getClassNo,bo.getClass_no());
        List<UserClassView> userClassViews = baseMapper.selectList(lqw);
        return userClassViews;
    }
}
